
#include "zen_vap_layer.h"

namespace Zen { namespace Vap {
	
	Layer::Layer()
	{
		
	}
	void Layer::draw()
	{
		if(m_nodes.empty()) return;
		
		this->sortNodes();
		this->drawNodes();
	}
	
	Node* Layer::touchDown(AppTouch const & touch) {
		this->sortNodes();
		return this->touchDownNodes(touch);
	}
	
	Layer2d::Layer2d()
	: Node2d(), PartWithMatrix2d(false)
	{
	}
	
	void Layer2d::draw()
	{
		if(m_nodes.empty()) return;
		
		DrawStack::GuardMatrix __gm(&this->getMatrix(), getMatrixVersion());
		DrawStack::GuardAlpha __ga(this->getAlpha());
		DrawStack::GuardBlend __gb(this->getBlend());
		
		this->sortNodes();
		this->drawNodes();
	}
	
	Node* Layer2d::touchDown(AppTouch const & touch) {
		this->sortNodes();
		return this->touchDownNodes(touch);
	}
	
	Layer3d::Layer3d()
	: Node3d()
	{
	}
	void Layer3d::draw()
	{
		if(m_nodes.empty()) return;
		
		DrawStack::GuardMatrix __gm(&this->getMatrix(), getMatrixVersion());
		
		this->sortNodes();
		this->drawNodes();
	}
	
	Node* Layer3d::touchDown(AppTouch const & touch) {
		this->sortNodes();
		return this->touchDownNodes(touch);
	}
}}
